//防抖
export function debounce(fn,deplay=500){
    let clearTime;
    return function(args){
        const vm=this;
        if(clearTime) clearTimeout(clearTime),clearTime="";
        clearTime=setTimeout(() => {
            fn.call(vm,args)
        }, deplay);
    }
}

//节流

function throttle(fn,deplay=500){
    let last,clearTime;
    return function(args){
        const vm=this,_args=args;
        let now=new Date().valueOf();
        if(last&&now<last+deplay){
            clearTimeout(clearTime);
            clearTime=setTimeout(function(){
                last=new Date().valueOf()
                fn.call(vm,args)
            },deplay)
        }else{
            last=new Date().valueOf()
        }

    }
}

export function  getSearchVal(name,search){
    const reg=new RegExp("(^\\?|\^|&)"+name+"=([^&]*)(&|$)"),
            result=search.match(reg)
    return result?decodeURIComponent(result[2]||""):''
}